<?php
namespace App\Service;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Config;
class Phpredis {
    const GAME_REDIS_KEY = 'default';
    protected static $store = []; 
    public static function Redis($instance = null){
        !$instance && $instance = self::GAME_REDIS_KEY;
        self::connection($instance);
        return self::$store[$instance];
    }   

    public static function connection($instance = null){
        !$instance && $instance = self::GAME_REDIS_KEY;
        $config = Config::get('database.redis.'.$instance);
        $redis = New \Redis();
        $redis->connect($config['host'], $config['port']);
        $redis->auth($config['password']);
        $redis->select($config['database']);

        self::$store[$instance] = $redis;
    }   
}

